<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>Test::MockObject - Perl extension for emulating troublesome interfaces - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Test-MockObject - MetaCPAN" href="https://metacpan.org/dist/Test-MockObject/releases.rss" />
        <link rel="canonical" href="./Test::MockObject.html" />
        <meta name="description" content="Perl extension for emulating troublesome interfaces" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/Test::MockObject" />
<meta name="twitter:title"       content="Test::MockObject" />
<meta name="twitter:description" content="Perl extension for emulating troublesome interfaces" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./Test::MockObject.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Test-MockObject was released.">
      <span class="relatize">22 Jan 2020 18:48:26 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/Test-MockObject">Test-MockObject</a>
  </li>
  <li>
    Module version: 1.20200122
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/Test-MockObject/source/lib/Test/MockObject.pm">Source</a>
    (<a href="https://metacpan.org/dist/Test-MockObject/source/lib/Test/MockObject.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/Test-MockObject/source/lib/Test">Browse</a>
    (<a href="https://metacpan.org/dist/Test-MockObject/source/lib/Test?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/Test-MockObject/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/Test-MockObject/contribute">How to Contribute</a>
    </li>
    <li>
        <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/chromatic/Test-MockObject">Repository</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-MockObject">Issues</a>
      (16)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Test-MockObject+1.20200122" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/T/Test-MockObject.html?oncpan=1&amp;distmat=1&amp;version=1.20200122&amp;grade=2" style="color: #090">6342</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/T/Test-MockObject.html?oncpan=1&amp;distmat=1&amp;version=1.20200122&amp;grade=3" style="color: #900">3</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/T/Test-MockObject.html?oncpan=1&amp;distmat=1&amp;version=1.20200122&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/CHROMATIC/Test-MockObject-1.20200122">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Test-MockObject who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 1
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/Test-MockObject-1.20200122/index.html">% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li>
      Perl: v5.8.0
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/Test-MockObject/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/C/CH/CHROMATIC/Test-MockObject-1.20200122.tar.gz">
      Download (<span itemprop="fileSize">29.58KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FCHROMATIC%2FTest-MockObject-1.20200122%2Flib%2FTest%2FMockObject.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Test-MockObject/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Test-MockObject/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:Test-MockObject">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="Test-MockObject">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Test/MockObject.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="CHROMATIC/Test-MockObject-1.20200122"
>1.20200122
  (CHROMATIC on 2020-01-22)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20191002"
>1.20191002
  (CHROMATIC on 2019-10-02)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20180705"
>1.20180705
  (CHROMATIC on 2018-07-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20161202"
>1.20161202
  (CHROMATIC on 2016-12-02)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20150527"
>1.20150527
  (CHROMATIC on 2015-05-27)</option>
<optgroup label="BackPAN">'
<option
  
  value="CHROMATIC/Test-MockObject-1.20150521"
>1.20150521
  (CHROMATIC on 2015-05-21)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20140408"
>1.20140408
  (CHROMATIC on 2014-04-08)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20140328"
>1.20140328
  (CHROMATIC on 2014-03-28)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20120301"
>1.20120301
  (CHROMATIC on 2012-03-01)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20110612"
>1.20110612
  (CHROMATIC on 2011-06-12)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20110606"
>1.20110606
  (CHROMATIC on 2011-06-06)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.09"
>1.09
  (CHROMATIC on 2008-05-27)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.08"
>1.08
  (CHROMATIC on 2007-06-29)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.07"
>1.07
  (CHROMATIC on 2006-10-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.06"
>1.06
  (CHROMATIC on 2006-04-21)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.05"
>1.05
  (CHROMATIC on 2006-04-09)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.04"
>1.04
  (CHROMATIC on 2006-03-18)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.03"
>1.03
  (CHROMATIC on 2006-03-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.02"
>1.02
  (CHROMATIC on 2005-12-24)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.01"
>1.01
  (CHROMATIC on 2005-08-27)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.00"
>1.00
  (CHROMATIC on 2005-07-12)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.20"
>0.20
  (CHROMATIC on 2004-12-15)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.15"
>0.15
  (CHROMATIC on 2004-11-14)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.14"
>0.14
  (CHROMATIC on 2004-03-26)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.13"
>0.13
  (CHROMATIC on 2003-12-20)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.12"
>0.12
  (CHROMATIC on 2003-02-06)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.11"
>0.11
  (CHROMATIC on 2003-01-11)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.10"
>0.10
  (CHROMATIC on 2003-01-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.09"
>0.09
  (CHROMATIC on 2002-07-12)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.08"
>0.08
  (CHROMATIC on 2002-06-26)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.07"
>0.07
  (CHROMATIC on 2002-06-22)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.06"
>0.06
  (CHROMATIC on 2002-06-20)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.05"
>0.05
  (CHROMATIC on 2002-06-10)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.04"
>0.04
  (CHROMATIC on 2002-05-01)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/CHROMATIC/Test-MockObject-1.20200122/diff/' + encodeURIComponent(this.value) + '/lib/Test/MockObject.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="CHROMATIC/Test-MockObject-1.20200122"
>1.20200122
  (CHROMATIC on 2020-01-22)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20191002"
>1.20191002
  (CHROMATIC on 2019-10-02)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20180705"
>1.20180705
  (CHROMATIC on 2018-07-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20161202"
>1.20161202
  (CHROMATIC on 2016-12-02)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20150527"
>1.20150527
  (CHROMATIC on 2015-05-27)</option>
<optgroup label="BackPAN">'
<option
  
  value="CHROMATIC/Test-MockObject-1.20150521"
>1.20150521
  (CHROMATIC on 2015-05-21)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20140408"
>1.20140408
  (CHROMATIC on 2014-04-08)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20140328"
>1.20140328
  (CHROMATIC on 2014-03-28)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20120301"
>1.20120301
  (CHROMATIC on 2012-03-01)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20110612"
>1.20110612
  (CHROMATIC on 2011-06-12)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20110606"
>1.20110606
  (CHROMATIC on 2011-06-06)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.09"
>1.09
  (CHROMATIC on 2008-05-27)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.08"
>1.08
  (CHROMATIC on 2007-06-29)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.07"
>1.07
  (CHROMATIC on 2006-10-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.06"
>1.06
  (CHROMATIC on 2006-04-21)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.05"
>1.05
  (CHROMATIC on 2006-04-09)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.04"
>1.04
  (CHROMATIC on 2006-03-18)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.03"
>1.03
  (CHROMATIC on 2006-03-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.02"
>1.02
  (CHROMATIC on 2005-12-24)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.01"
>1.01
  (CHROMATIC on 2005-08-27)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.00"
>1.00
  (CHROMATIC on 2005-07-12)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.20"
>0.20
  (CHROMATIC on 2004-12-15)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.15"
>0.15
  (CHROMATIC on 2004-11-14)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.14"
>0.14
  (CHROMATIC on 2004-03-26)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.13"
>0.13
  (CHROMATIC on 2003-12-20)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.12"
>0.12
  (CHROMATIC on 2003-02-06)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.11"
>0.11
  (CHROMATIC on 2003-01-11)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.10"
>0.10
  (CHROMATIC on 2003-01-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.09"
>0.09
  (CHROMATIC on 2002-07-12)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.08"
>0.08
  (CHROMATIC on 2002-06-26)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.07"
>0.07
  (CHROMATIC on 2002-06-22)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.06"
>0.06
  (CHROMATIC on 2002-06-20)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.05"
>0.05
  (CHROMATIC on 2002-06-10)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.04"
>0.04
  (CHROMATIC on 2002-05-01)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="https://metacpan.org/pod/Carp" title="Carp" class="ellipsis">Carp</a></li>
  <li><a href="https://metacpan.org/pod/Devel::Peek" title="Devel::Peek" class="ellipsis">Devel::Peek</a></li>
  <li><a href="https://metacpan.org/pod/Scalar::Util" title="Scalar::Util" class="ellipsis">Scalar::Util</a></li>
  <li><a href="https://metacpan.org/pod/Test::Builder" title="Test::Builder" class="ellipsis">Test::Builder</a></li>
  <li><a href="https://metacpan.org/pod/UNIVERSAL::can" title="UNIVERSAL::can" class="ellipsis">UNIVERSAL::can</a></li>
  <li><a href="https://metacpan.org/pod/UNIVERSAL::isa" title="UNIVERSAL::isa" class="ellipsis">UNIVERSAL::isa</a></li>
  <li><a href="https://metacpan.org/pod/constant" title="constant" class="ellipsis">constant</a></li>
  <li><a href="https://metacpan.org/pod/strict" title="strict" class="ellipsis">strict</a></li>
  <li><a href="https://metacpan.org/pod/warnings" title="warnings" class="ellipsis">warnings</a></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/Test::MockObject/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=Test%3A%3AMockObject">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=Test-MockObject">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/CHROMATIC/Test-MockObject-1.20200122/view/lib/Test/MockObject.pm">This version</a>
    </li>
    <li>
      <a href="./Test::MockObject.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/BRTASTIC"><img src="https://www.gravatar.com/avatar/ee4e20f351921e70f1985c5623e709e5?d=identicon&amp;s=20" title="BRTASTIC" alt="BRTASTIC"></a>
<a class="display-all" href="https://metacpan.org/author/FILIN"><img src="https://www.gravatar.com/avatar/9939ecca1e7c2e67e132298fe20e1086?d=identicon&amp;s=20" title="FILIN" alt="FILIN"></a>
<a class="display-all" href="https://metacpan.org/author/MJEMMESON"><img src="https://www.gravatar.com/avatar/e17c4cf81cbd75b5043884252c378c47?d=identicon&amp;s=20" title="MJEMMESON" alt="MJEMMESON"></a>
<a class="display-all" href="https://metacpan.org/author/HANENKAMP"><img src="https://www.gravatar.com/avatar/e5b51c69496e22e3e2d037604cc6d8c9?d=identicon&amp;s=20" title="HANENKAMP" alt="HANENKAMP"></a>
<a class="display-all" href="https://metacpan.org/author/DBOEHMER"><img src="https://www.gravatar.com/avatar/220fbe10dba79664fe84771d5ea32763?d=identicon&amp;s=20" title="DBOEHMER" alt="DBOEHMER"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/Test-MockObject/plussers">18 PAUSE users</a>
</div>
<div>
    7 non-PAUSE users
</div>
</div>
    </li>
    <li>
<div id="metacpan_contributors">
  <div>
    <button class="btn-link"
      onclick="$(this).hide(); $('#metacpan_contributors ul').slideDown(); return false;"
    >and 1 contributors</button>
  </div>
  <ul style="display: none">
    <li class="contributor"
    >
      chromatic
    </li>
  </ul>
</div>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/CHROMATIC" class="author-name">chromatic</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Test/MockObject.pm&#39;" class="">
<option
  selected
  value="CHROMATIC/Test-MockObject-1.20200122"
>1.20200122
  (CHROMATIC on 2020-01-22)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20191002"
>1.20191002
  (CHROMATIC on 2019-10-02)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20180705"
>1.20180705
  (CHROMATIC on 2018-07-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20161202"
>1.20161202
  (CHROMATIC on 2016-12-02)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20150527"
>1.20150527
  (CHROMATIC on 2015-05-27)</option>
<optgroup label="BackPAN">'
<option
  
  value="CHROMATIC/Test-MockObject-1.20150521"
>1.20150521
  (CHROMATIC on 2015-05-21)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20140408"
>1.20140408
  (CHROMATIC on 2014-04-08)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20140328"
>1.20140328
  (CHROMATIC on 2014-03-28)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20120301"
>1.20120301
  (CHROMATIC on 2012-03-01)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20110612"
>1.20110612
  (CHROMATIC on 2011-06-12)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.20110606"
>1.20110606
  (CHROMATIC on 2011-06-06)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.09"
>1.09
  (CHROMATIC on 2008-05-27)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.08"
>1.08
  (CHROMATIC on 2007-06-29)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.07"
>1.07
  (CHROMATIC on 2006-10-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.06"
>1.06
  (CHROMATIC on 2006-04-21)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.05"
>1.05
  (CHROMATIC on 2006-04-09)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.04"
>1.04
  (CHROMATIC on 2006-03-18)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.03"
>1.03
  (CHROMATIC on 2006-03-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.02"
>1.02
  (CHROMATIC on 2005-12-24)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.01"
>1.01
  (CHROMATIC on 2005-08-27)</option>
<option
  
  value="CHROMATIC/Test-MockObject-1.00"
>1.00
  (CHROMATIC on 2005-07-12)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.20"
>0.20
  (CHROMATIC on 2004-12-15)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.15"
>0.15
  (CHROMATIC on 2004-11-14)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.14"
>0.14
  (CHROMATIC on 2004-03-26)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.13"
>0.13
  (CHROMATIC on 2003-12-20)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.12"
>0.12
  (CHROMATIC on 2003-02-06)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.11"
>0.11
  (CHROMATIC on 2003-01-11)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.10"
>0.10
  (CHROMATIC on 2003-01-05)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.09"
>0.09
  (CHROMATIC on 2002-07-12)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.08"
>0.08
  (CHROMATIC on 2002-06-26)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.07"
>0.07
  (CHROMATIC on 2002-06-22)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.06"
>0.06
  (CHROMATIC on 2002-06-20)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.05"
>0.05
  (CHROMATIC on 2002-06-10)</option>
<option
  
  value="CHROMATIC/Test-MockObject-0.04"
>0.04
  (CHROMATIC on 2002-05-01)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/Test-MockObject">Test-MockObject-1.20200122</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage three &#10;
          • 257 direct dependents &#10;          • 527 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="Test-MockObject-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="Test-MockObject-1.20200122">
    <input type="hidden" name="author" value="CHROMATIC">
    <input type="hidden" name="distribution" value="Test-MockObject">
    <button type="submit" class="favorite highlight"><span>25</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./Test::MockObject.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>25</span> ++</a>
</div>
   / <span>Test::MockObject</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./Test::MockObject.html#NAME">NAME</a></li>
  <li><a href="./Test::MockObject.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./Test::MockObject.html#DESCRIPTION">DESCRIPTION</a>
    <ul>
      <li><a href="./Test::MockObject.html#IMPORTANT-CAVEATS">IMPORTANT CAVEATS</a></li>
      <li><a href="./Test::MockObject.html#EXPORT">EXPORT</a></li>
      <li><a href="./Test::MockObject.html#METHODS">METHODS</a>
        <ul>
          <li><a href="./Test::MockObject.html#The-Basics">The Basics</a></li>
          <li><a href="./Test::MockObject.html#Mocking">Mocking</a></li>
          <li><a href="./Test::MockObject.html#Checking-Your-Mocks">Checking Your Mocks</a></li>
          <li><a href="./Test::MockObject.html#Logging">Logging</a></li>
          <li><a href="./Test::MockObject.html#Subclassing">Subclassing</a></li>
        </ul>
      </li>
    </ul>
  </li>
  <li><a href="./Test::MockObject.html#TODO">TODO</a></li>
  <li><a href="./Test::MockObject.html#AUTHOR">AUTHOR</a></li>
  <li><a href="./Test::MockObject.html#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="./Test::MockObject.html#COPYRIGHT">COPYRIGHT</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>Test::MockObject - Perl extension for emulating troublesome interfaces</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>  use Test::MockObject;
  my $mock = Test::MockObject-&gt;new();
  $mock-&gt;set_true( &#39;somemethod&#39; );
  ok( $mock-&gt;somemethod() );

  $mock-&gt;set_true( &#39;veritas&#39;)
       -&gt;set_false( &#39;ficta&#39; )
       -&gt;set_series( &#39;amicae&#39;, &#39;Sunny&#39;, &#39;Kylie&#39;, &#39;Bella&#39; );</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>It&#39;s a simple program that doesn&#39;t use any other modules, and those are easy to test. More often, testing a program completely means faking up input to another module, trying to coax the right output from something you&#39;re not supposed to be testing anyway.</p>

<p>Testing is a lot easier when you can control the entire environment. With Test::MockObject, you can get a lot closer.</p>

<p>Test::MockObject allows you to create objects that conform to particular interfaces with very little code. You don&#39;t have to reimplement the behavior, just the input and the output.</p>

<h2 id="IMPORTANT-CAVEATS"><a id="IMPORTANT"></a>IMPORTANT CAVEATS</h2>

<p>Before you go wild with your testing powers, consider three caveats:</p>

<ul>

<li><p>It is possible to write highly detailed unit tests that pass even when your integration tests may fail. Testing the pieces individually does not excuse you from testing the whole thing together.</p>

</li>
<li><p>In cases where you only need to mock one or two pieces of an existing module, consider <a href="https://metacpan.org/pod/Test::MockObject::Extends">Test::MockObject::Extends</a> instead.</p>

</li>
<li><p>If the code under testing produces strange errors about type checks, pass the <code>-debug</code> flag when using <code>Test::MockObject</code> or <code>Test::MockObject::Extends</code>. This will load both <a href="https://metacpan.org/pod/UNIVERSAL::isa">UNIVERSAL::isa</a> and <a href="https://metacpan.org/pod/UNIVERSAL::can">UNIVERSAL::can</a> to perform additional debugging on the incorrect use of both methods from the <a href="https://metacpan.org/pod/UNIVERSAL">UNIVERSAL</a> package. (This behavior used to be active by default, but that was, however correct, probably a burden to onerous for the CPAN.)</p>

</li>
</ul>

<h2 id="EXPORT">EXPORT</h2>

<p>None.</p>

<h2 id="METHODS">METHODS</h2>

<p>The most important thing a Mock Object can do is to conform sufficiently to an interface. For example, if you&#39;re testing something that relies on CGI.pm, you may find it easier to create a mock object that returns controllable results at given times than to fake query string input.</p>

<h3 id="The-Basics"><a id="The"></a>The Basics</h3>

<ul>

<li><p><code>new</code></p>

<p>Creates a new mock object. By default, this is a blessed hash. Pass a reference to bless that reference.</p>

<pre><code>    my $mock_array  = Test::MockObject-&gt;new( [] );
    my $mock_scalar = Test::MockObject-&gt;new( \( my $scalar ) );
    my $mock_code   = Test::MockObject-&gt;new( sub {} );
    my $mock_glob   = Test::MockObject-&gt;new( \*GLOB );</code></pre>

</li>
</ul>

<h3 id="Mocking">Mocking</h3>

<p>Your mock object is nearly useless if you don&#39;t tell it what it&#39;s mocking. This is done by installing methods. You control the output of these mocked methods. In addition, any mocked method is tracked. You can tell not only what was called, but which arguments were passed. Please note that you cannot track non-mocked method calls. They will still be allowed, though Test::MockObject will carp() about them. This is considered a feature, though it may be possible to disable this in the future.</p>

<p>As implied in the example above, it&#39;s possible to chain these calls together. Thanks to a suggestion from the fabulous Piers Cawley (CPAN RT #1249), this feature came about in version 0.09. Shorter testing code is nice!</p>

<ul>

<li><p><code>mock(<i>name</i>, <i>coderef</i> [, <i>name2</i>, <i>coderef2</i>, ...])</code></p>

<p>Adds one or more coderefs to the object. This allows code to call the named methods on the object. For example, this code:</p>

<pre><code>    my $mock = Test::MockObject-&gt;new();
    $mock-&gt;mock( &#39;fluorinate&#39;,
        sub { &#39;impurifying precious bodily fluids&#39; } );
    print $mock-&gt;fluorinate;</code></pre>

<p>will print a helpful warning message. Please note that methods are only added to a single object at a time and not the class. (There is no small similarity to the Self programming language or the <a href="https://metacpan.org/pod/Class::Prototyped">Class::Prototyped</a> module.)</p>

<p>This method forms the basis for most of Test::MockObject&#39;s testing goodness.</p>

<p><b>Please Note:</b> this method used to be <code>add()</code>. Due to its ambiguity, it now has a different spelling. For backwards compatibility purposes, add() is available, though version 0.07 deprecated it. It goes to some contortions to try to do what you mean, but I make few guarantees.</p>

</li>
<li><p><code>fake_module(<i>module name</i>), [ <i>subname</i> =</code> <i>coderef</i>, ... ]</p>

<p><b>Note:</b> See <a href="https://metacpan.org/pod/Test::MockModule">Test::MockModule</a> for an alternate (and better) approach.</p>

<p>Lies to Perl that it has already loaded a named module. This is handy when providing a mockup of a real module if you&#39;d like to prevent the actual module from interfering with the nice fakery. If you&#39;re mocking <a href="https://metacpan.org/pod/Regexp::English">Regexp::English</a>, say:</p>

<pre><code>    $mock-&gt;fake_module( &#39;Regexp::English&#39; );</code></pre>

<p>This is both a class and as an object method. Beware that this must take place before the actual module has a chance to load. Either wrap it in a BEGIN block before a use or require or place it before a <code>use_ok()</code> or <code>require_ok()</code> call.</p>

<p>You can optionally add functions to the mocked module by passing them as name =&gt; coderef pairs to <code>fake_module()</code>. This is handy if you want to test an <code>import()</code>:</p>

<pre><code>    my $import;
    $mock-&gt;fake_module(
        &#39;Regexp::English&#39;,
        import =&gt; sub { $import = caller }
    );
    use_ok( &#39;Regexp::Esperanto&#39; );
    is( $import, &#39;Regexp::Esperanto&#39;,
        &#39;Regexp::Esperanto should use() Regexp::English&#39; );</code></pre>

<p>If you use <code>fake_module()</code> to mock a module that already exists in memory -- one you&#39;ve loaded elsewhere perhaps, but do not pass any subroutines to mock, this method will throw an exception. This is because if you call the constructor later on, you probably won&#39;t get a mock object back and you&#39;ll be confused.</p>

</li>
<li><p><code>fake_new(<i>module name</i>)</code></p>

<p><b>Note:</b> see <a href="https://metacpan.org/pod/Test::MockObject::Extends">Test::MockObject::Extends</a> for a better alternative to this method.</p>

<p>Provides a fake constructor for the given module that returns the invoking mock object. Used in conjunction with <code>fake_module()</code>, you can force the tested unit to work with the mock object instead.</p>

<pre><code>    $mock-&gt;fake_module( &#39;CGI&#39; );
    $mock-&gt;fake_new( &#39;CGI&#39; );

    use_ok( &#39;Some::Module&#39; );
    my $s = Some::Module-&gt;new();
    is( $s-&gt;{_cgi}, $mock,
        &#39;new() should create and store a new CGI object&#39; );</code></pre>

</li>
<li><p><code>set_always(<i>name</i>, <i>value</i>)</code></p>

<p>Adds a method of the specified name that always returns the specified value.</p>

</li>
<li><p><code>set_true(<i>name_1</i>, <i>name_2</i>, ... <i>name_n</i>)</code></p>

<p>Adds a method of the specified name that always returns a true value. This can take a list of names.</p>

</li>
<li><p><code>set_false(<i>name_1</i>, <i>name_2</i>, ... <i>name_n</i>)</code></p>

<p>Adds a method of the specified name that always returns a false value. (Since it installs an empty subroutine, the value should be false in both scalar and list contexts.) This can take a list of names.</p>

</li>
<li><p><code>set_list(<i>name</i>, [ <i>item1</i>, <i>item2</i>, ... ]</code></p>

<p>Adds a method that always returns a given list of values. It takes some care to provide a list and not an array, if that&#39;s important to you.</p>

</li>
<li><p><code>set_series(<i>name</i>, [ <i>item1</i>, <i>item2</i>, ... ]</code></p>

<p>Adds a method that will return the next item in a series on each call. This can help to test error handling, by forcing a failure on the first method call and then subsequent successes. Note that the series does not repeat; it will eventually run out.</p>

</li>
<li><p><code>set_bound(<i>name</i>, <i>reference</i>)</code></p>

<p>Adds a method bound to a variable. Pass in a reference to a variable in your test. When you change the variable, the return value of the new method will change as well. This is often handier than replacing mock methods.</p>

</li>
<li><p><code>set_isa( <i>name1</i>, <i>name2</i>, ... <i>namen</i> )</code></p>

<p>Adds an apparent parent to the module, so that calling <code>isa()</code> on the mock will return true appropriately. Sometimes you really need this.</p>

</li>
<li><p><code>remove(<i>name</i>)</code></p>

<p>Removes a named method.</p>

</li>
</ul>

<h3 id="Checking-Your-Mocks"><a id="Checking"></a>Checking Your Mocks</h3>

<ul>

<li><p><code>can( $method_name )</code></p>

<p>Returns a subroutine reference if this particular mocked object can handle the named method, false otherwise.</p>

</li>
<li><p><code>isa( $class_name )</code></p>

<p>Returns true if the invocant object mocks a particular class. You must have used <code>set_isa()</code> first.</p>

</li>
<li><p><code>called(<i>name</i>)</code></p>

<p>Checks to see if something has called a named method on the object. This returns a boolean value. The current implementation does not scale especially well, so use this sparingly if you need to search through hundreds of calls.</p>

</li>
<li><p><code>clear()</code></p>

<p>Clears the internal record of all method calls on the object. It&#39;s handy to do this every now and then. Note that this does not affect the mocked methods, only all of the methods called on the object to this point.</p>

<p>It&#39;s handy to <code>clear()</code> methods in between series of tests. That makes it much easier to call <code>next_method()</code> without having to skip over the calls from the last set of tests.</p>

</li>
<li><p><code>next_call([ <i>position</i> ])</code></p>

<p>Returns the name and argument list of the next mocked method called on an object, in list context. In scalar context, returns only the method name. There are two important things to know about this method. First, it starts at the beginning of the call list. If your code runs like this:</p>

<pre><code>    $mock-&gt;set_true( &#39;foo&#39; );
    $mock-&gt;set_true( &#39;bar&#39; );
    $mock-&gt;set_true( &#39;baz&#39; );

    $mock-&gt;foo();
    $mock-&gt;bar( 3, 4 );
    $mock-&gt;foo( 1, 2 );</code></pre>

<p>Then you might see output of:</p>

<pre><code>    my ($name, $args) = $mock-&gt;next_call();
    print &quot;$name (@$args)&quot;;

    # prints &#39;foo&#39;

    $name = $mock-&gt;next_call();
    print $name;

    # prints &#39;bar&#39;

    ($name, $args) = $mock-&gt;next_call();
    print &quot;$name (@$args)&quot;;

    # prints &#39;foo 1 2&#39;</code></pre>

<p>If you provide an optional number as the <i>position</i> argument, the method will skip that many calls, returning the data for the last one skipped.</p>

<pre><code>    $mock-&gt;foo();
    $mock-&gt;bar();
    $mock-&gt;baz();

    $name = $mock-&gt;next_call();
    print $name;

    # prints &#39;foo&#39;

    $name = $mock-&gt;next_call( 2 );
    print $name

    # prints &#39;baz&#39;</code></pre>

<p>When it reaches the end of the list, it returns undef. This is probably the most convenient method in the whole module, but for the sake of completeness and backwards compatibility (it takes me a while to reach the truest state of laziness!), there are several other methods.</p>

</li>
<li><p><code>call_pos(<i>position</i>)</code></p>

<p>Returns the name of the method called on the object at a specified position. This is handy if you need to test a certain order of calls. For example:</p>

<pre><code>    Some::Function( $mock );
    is( $mock-&gt;call_pos(1),  &#39;setup&#39;,
        &#39;Function() should first call setup()&#39; );
    is( $mock-&gt;call_pos(-1), &#39;end&#39;,
        &#39;... and last call end()&#39; );</code></pre>

<p>Positions can be positive or negative. Please note that the first position is, in fact, 1. (This may change in the future. I like it, but am willing to reconsider.)</p>

</li>
<li><p><code>call_args(<i>position</i>)</code></p>

<p>Returns a list of the arguments provided to the method called at the appropriate position. Following the test above, one might say:</p>

<pre><code>    is( ($mock-&gt;call_args(1))[0], $mock,
        &#39;... passing the object to setup()&#39; );
    is( scalar $mock-&gt;call_args(-1), 0,
        &#39;... and no args to end()&#39; );</code></pre>

</li>
<li><p><code>call_args_pos(<i>call position</i>, <i>argument position</i>)</code></p>

<p>Returns the argument at the specified position for the method call at the specified position. One might rewrite the first test of the last example as:</p>

<pre><code>    is( $mock-&gt;call_args_pos(1, 1), $mock,
        &#39;... passing the object to setup()&#39;);</code></pre>

</li>
<li><p><code>call_args_string(<i>position</i>, [ <i>separator</i> ])</code></p>

<p>Returns a stringified version of the arguments at the specified position. If no separator is given, they will not be separated. This can be used as:</p>

<pre><code>    is( $mock-&gt;call_args_string(1), &quot;$mock initialize&quot;,
        &#39;... passing object, initialize as arguments&#39; );</code></pre>

</li>
<li><p><code>called_ok(<i>method name</i>, [ <i>test name</i> ])</code></p>

<p>Tests to see whether a method of the specified name has been called on the object. This and the following methods use Test::Builder, so they integrate nicely with a test suite built around Test::Simple, Test::More, or anything else compatible:</p>

<pre><code>    $mock-&gt;foo();
    $mock-&gt;called_ok( &#39;foo&#39; );</code></pre>

<p>A generic default test name is provided.</p>

</li>
<li><p><code>called_pos_ok(<i>position</i>, <i>method name</i>, [ <i>test name</i> ])</code></p>

<p>Tests to see whether the named method was called at the specified position. A default test name is provided.</p>

</li>
<li><p><code>called_args_pos_is(<i>method position</i>, <i>argument position</i>, <i>expected</i>, [ <i>test name</i> ])</code></p>

<p>Tests to see whether the argument at the appropriate position of the method in the specified position equals a specified value. A default, rather non-descript test name is provided.</p>

</li>
<li><p><code>called_args_string_is(<i>method position</i>, <i>separator</i>, <i>expected</i>, [ <i>test name</i> ])</code></p>

<p>Joins together all of the arguments to a method at the appropriate position and matches against a specified string. A generically bland test name is provided by default. You can probably do much better.</p>

</li>
<li><p><code>check_class_loaded( $class_name )</code></p>

<p>Attempts to determine whether you have a class of the given name loaded and compiled. Returns true or false.</p>

</li>
</ul>

<h3 id="Logging">Logging</h3>

<p>Test::MockObject logs all mocked methods by default. Sometimes you don&#39;t want to do this. To prevent logging all calls to a given method, prepend the name of the method with <code>-</code> when mocking it.</p>

<p>That is:</p>

<pre><code>    $mock-&gt;set_true( &#39;-foo&#39;, &#39;bar&#39; );</code></pre>

<p>will set mock both <code>foo()</code> and <code>bar()</code>, causing both to return true. However, the object will log only calls to <code>bar()</code>, not <code>foo()</code>. To log <code>foo()</code> again, merely mock it again without the leading <code>-</code>:</p>

<pre><code>    $mock-&gt;set_true( &#39;foo&#39; );</code></pre>

<p><code>$mock</code> will log all subsequent calls to <code>foo()</code> again.</p>

<h3 id="Subclassing">Subclassing</h3>

<p>There are two methods provided for subclassing:</p>

<ul>

<li><p><code>dispatch_mocked_method( $method_name, @_ )</code></p>

<p>This method determines how to call a method (named as <code>$method_name</code>) not available in this class. It also controls logging. You may or may not find it useful, but I certainly take advantage of it for Test::MockObject::Extends.</p>

</li>
<li><p><code>log_call( $method_name, @_ )</code></p>

<p>This method tracks the call of the named method and its arguments.</p>

</li>
</ul>

<h1 id="TODO">TODO</h1>

<ul>

<li><p>Add a factory method to avoid namespace collisions (soon)</p>

</li>
<li><p>Add more useful methods (catch <code>import()</code>?)</p>

</li>
</ul>

<h1 id="AUTHOR">AUTHOR</h1>

<p>chromatic, &lt;chromatic at wgz dot org&gt;</p>

<p>Thanks go to Curtis &#39;Ovid&#39; Poe, as well as ONSITE! Technology, Inc., for finding several bugs and providing several constructive suggestions.</p>

<p>Jay Bonci also found a false positive in <code>called_ok()</code>. Thanks!</p>

<p>Chris Winters was the first to report I&#39;d accidentally scheduled 0.12 for deletion without uploading a newer version. He also gave useful feedback on Test::MockObject::Extends.</p>

<p>Stevan Little provided the impetus and code for <code>set_isa()</code>.</p>

<p>Nicholas Clark found a documentation error.</p>

<p>Mutant suggested a potential problem with fake_module().</p>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<p><a href="https://metacpan.org/pod/perl">perl</a>, <a href="https://metacpan.org/pod/Test::Tutorial">Test::Tutorial</a>, <a href="https://metacpan.org/pod/Test::More">Test::More</a>, <a href="https://metacpan.org/pod/http://www.perl.com/pub/a/2001/12/04/testing.html">http://www.perl.com/pub/a/2001/12/04/testing.html</a>, and <a href="https://metacpan.org/pod/http://www.perl.com/pub/a/2002/07/10/tmo.html">http://www.perl.com/pub/a/2002/07/10/tmo.html</a>.</p>

<h1 id="COPYRIGHT">COPYRIGHT</h1>

<p>Copyright (c) 2002 - 2016 by chromatic &lt;chromatic at wgz dot org&gt;.</p>

<p>This program is free software; you can use, modify, and redistribute it under the same terms as Perl 5.24 itself.</p>

<p>See http://www.perl.com/perl/misc/Artistic.html</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install Test::MockObject, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm Test::MockObject</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install Test::MockObject</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./Test::MockObject.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
